package com.itheima.wemedia.vo;

import com.itheima.common.util.RequestContextUtil;
import com.itheima.wemedia.pojo.WmNews;
import com.itheima.wemedia.pojo.WmUser;
import lombok.Data;
import org.springframework.beans.BeanUtils;

@Data
public class WmNewsVo extends WmNews {

    //作者名称
    private String authorName;

    //app端用户id 文章同步需用到
    private Long apUserId;

    /**
     * 构建WmNewsVo对象的方法
     * @param wmNews
     * @param wmUser
     * @return
     */
    /*public static WmNewsVo build(WmNews wmNews,String authorName){
        WmNewsVo wmNewsVo = new WmNewsVo();
        BeanUtils.copyProperties(wmNews,wmNewsVo);
        wmNewsVo.setAuthorName(authorName);
        return wmNewsVo;
    }*/
    public static WmNewsVo build(WmNews wmNews, WmUser wmUser){
        WmNewsVo vo = new WmNewsVo();
        BeanUtils.copyProperties(wmNews, vo);
        vo.setAuthorName(wmUser.getName());
        vo.setApUserId(wmUser.getApUserId());
        return vo;
    }
}
